package com.codeczx.pageradapter;

import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    private ViewPager viewPager;
    private MyPagerAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        viewPager = (ViewPager) findViewById(R.id.view_pager);
        List<BlankFragment>list = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            list.add(BlankFragment.newInstance("fragment"+i));
        }
        adapter = new MyPagerAdapter(getSupportFragmentManager(),list);
        viewPager.setAdapter(adapter);
    }
}
